/*
* Portuguese eID Card API .NET Wrapper
*
* Written by Fernando Nunes (fernando.nunes@devscope.net)
* Copyright (c) 2009 DevScope Information Systems
*
* This library is free software; you can redistribute it and/or 
* modify it under the terms of the GNU Lesser General Public 
* License as published by the Free Software Foundation; either 
* version 2.1 of the License, or (at your option) any later version. 
* 
* This library is distributed in the hope that it will be useful, 
* but WITHOUT ANY WARRANTY; without even the implied warranty of 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
* Lesser General Public License for more details. 
* 
* You should have received a copy of the GNU Lesser General Public 
* License along with this library; if not, write to the Free Software 
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 
*/ 

#pragma once
#include "pteidlib.h"

using namespace System;

namespace DevScope
{	
	namespace CartaoDeCidadao
	{
		/// <summary>Pin Ids used on IAS 0.7 cards</summary>
		public enum class PinId
		{
			/// <summary>Id of PIN used for Authorizing the Citizen</summary>
			AUTHORIZATION_PIN_ID	= PTEID_AUTH_PIN_ID,
			/// <summary>Id of PIN used for using the Citizen's Digital Signature</summary>
			SIGNATURE_PIN_ID			= PTEID_SIG_PIN_ID,
			/// <summary>Id of PIN used for Requesting Citizen's Address Data</summary>
			ADDRESS_PIN_ID				= PTEID_ADDRESS_PIN_ID
		};

		/// <summary>Pin Ids used on IAS 1.0.1 cards</summary>
		public enum class PinIdv101
		{
			/// <summary>Id of PIN used for Authorizing the Citizen</summary>
			AUTHORIZATION_PIN_ID	= PTEID_AUTH_PIN_ID_101,
			/// <summary>Id of PIN used for using the Citizen's Digital Signature</summary>
			SIGNATURE_PIN_ID		= PTEID_SIG_PIN_ID_101,
			/// <summary>Id of PIN used for Requesting Citizen's Address Data</summary>
			ADDRESS_PIN_ID			= PTEID_ADDRESS_PIN_ID_101
		};

		/// <summary>Available Pin Types</summary>
		public enum class PinType
		{
			/// <summary>PKCS#15 PIN</summary>
			PKCS15	= PTEID_PIN_TYPE_PKCS15,
			/// <summary>OS PIN</summary>
			OS		= PTEID_PIN_TYPE_OS
		};

		/// <summary>Pin Unblock Flags</summary>
		public enum class PinUnblockType
		{
			/// <summary>For testing purposes</summary>
			NONE				= 0,
			/// <summary>Generates new PIN</summary>
			NEW_PIN			= UNBLOCK_FLAG_NEW_PIN,
			/// <summary>Unkown</summary>
			PUK_MERGE		=	UNBLOCK_FLAG_PUK_MERGE
		};

		/// <summary>Pin Usage Types</summary>
		public enum class PinUsage
		{
			/// <summary>Used for Authorization</summary>
			AUTHORIZATION = PTEID_USAGE_AUTH,
			/// <summary>Used for Digital Signatures</summary>
			SIGNATURE		  = PTEID_USAGE_SIGN
		};

		/// <summary>Change CapPin Operation States</summary>
		public enum class CapPinChangeState 
		{
			/// <summary>Initialising</summary>
			INITIALISING	= CAP_INITIALISING,
			/// <summary>Connecting to the Server (PIN is asked)</summary>
			CONNECTING		= CAP_CONNECTING,
			/// <summary>Reading info from the card</summary>
			READING_INFO	= CAP_READING_INFO,
			/// <summary>Sending info to the server</summary>
			SENDING_INFO	= CAP_SENDING_INFO,
			/// <summary>Change the PIN in the card</summary>
			WRITE					= CAP_WRITE,
			/// <summary>Finish the CAP PIN change(send responses to the server)</summary>
			FINISH				= CAP_FINISH,
			/// <summary>The CAP PIN Change flow has completed.</summary>
			FINISHED			= CAP_FINISHED,
			/// <summary>The CAP PIN Change flow was cancelled.</summary>
			CANCELLED			= CAP_CANCELLED
		};

		/// <summary>
		/// Card/Citizen PIN information
		/// </summary>
		public ref class Pin
		{
		internal:
			Pin(const PTEID_Pin& i);

		public:
			/// <summary>Refer to <see cref="PinId"/> or <see cref="PinIdv101"/> depending on the card version.</summary>
			Byte Id;
			/// <summary>The underlying type of the PIN.</summary>
			PinType Type;
			/// <summary>The purpose of the PIN.</summary>
			PinUsage Usage;
			/// <summary>The number of tries left until the PIN gets blocked.</summary>
			long TriesLeft;
			/// <summary></summary>
			long Flags;
			/// <summary>The name of the PIN.</summary>
			String^ Label;
			/// <summary>May be NULL for usage known by the middleware.</summary>
			String^ ShortUsage;
			/// <summary>May be NULL for usage known by the middleware.</summary>
			String^ LongUsage;
		};
	}
}